home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk11
/
cprof12
/
p-sieve.rpt
< prev
next >
Wrap
Text File
|
1995-03-18
|
1KB
|
57 lines
C Profiler. (c) 1987 by Michael F Purcell
Statement Execution Report
:/*****************************************************************************
: ***
: *** The Sieve of Eratosthenes
: ***
: ***/
:
:#include "time.h"
:#include "stdio.h"
:#define size 8190
:unsigned char flag[size+1];
:void main()
:{
: register int i,k,p,primes;
: int iter;
: long t1,t2;
:
:
1: time(&t1);
1: for (iter=1;iter<=100;iter++)
1: {
1:
100: for (i=0;i<=size;i++)
100:
819100: flag[i]=1;
819100:
819100:
819100:
100: primes=0;
100: for (i=0;i<=size;i++)
100: {
819100: if (flag[i]==1)
819100: {
189900: p=i+i+3;
189900: for(k=i+p;k<=size;k+=p)
189900:
1499900: flag[k]=0;
1499900:
1499900:
189900: primes++;
189900: }
189900:
819100: }
819100:
100: }
100:
1: time(&t2);
1: printf("primes=%d in %ld seconds for 100 iterations\n",primes,(t2-t1));
1:
1:}
:
:
: